package top.hkyzf.study.j2se.juc;

import java.util.concurrent.*;

/**
 * @author 朱峰
 * @date 2021-12-28 23:11
 */
public class ThreadDemo4 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService executorService = Executors.newSingleThreadExecutor();
        Future<Integer> future = executorService.submit(new MyCallable2());
        Integer integer = future.get();
        System.out.println("线程：" + Thread.currentThread().getName() + " 执行了！");
        System.out.println(integer);
        executorService.shutdown();
    }
}

class MyCallable2 implements Callable<Integer> {
    @Override
    public Integer call() {
        System.out.println("线程：" + Thread.currentThread().getName() + " 执行了！");
        return 1 + 1;
    }
}
